# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=bad-pdf
pkgver=v1.1.r31.g4b42f66
pkgrel=2
epoch=1
pkgdesc='Steal NTLM Hashes with Bad-PDF.'
groups=('blackarch' 'blackarch-exploitation')
arch=('any')
url='https://github.com/deepzec/Bad-Pdf'
license=('GPL3')
depends=('python' 'responder')
makedepends=('git')
source=("$pkgname::git+https://github.com/deepzec/Bad-Pdf.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec python /usr/share/$pkgname/badpdf.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

